home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / SAT 2.3.8 / Demos / StepPlatform Demo ƒ / InformUser.p < prev    next >
Text File  |  1996-05-11  |  3KB  |  153 lines

  1. (**************************************}
  2. {* displaying information on the screen}
  3. {*    and updating it.}
  4. {**************************************)
  5.  
  6. unit InformUser;
  7. interface
  8.     uses
  9. {$ifc UNDEFINED THINK_PASCAL}
  10.         Types, QuickDraw, Menus, Windows, TextEdit, Fonts,{}
  11.         Dialogs, Memory, ToolUtils, TextUtils, QuickDrawText, {}
  12. {$endc}
  13.         SAT, PlatformGlobals, sPlayerSprite;
  14.  
  15.     procedure InitInformationArea;
  16.     procedure DrawProgInfo (me: PlSpritePtr);
  17.     procedure UpdateInfo (me: PlSpritePtr);
  18.     procedure DrawProgrammerInfo;
  19.  
  20. implementation
  21.  
  22. {var SpritePtr    playerSp:extern; {Skall fixas genom uses!}
  23.  
  24.  
  25.     var
  26.         aActionMsg: array[0..10] of Str255;
  27.         lastActMsg: Integer;
  28.  
  29.     procedure InitInformationArea;
  30.         var
  31.             sh: StringHandle;
  32.             i: Integer;
  33.             r: Rect;
  34.             tmpPort: SATPort;
  35.  
  36.     begin
  37.         lastActMsg := -1;
  38.         i := 0;
  39.         repeat
  40.             begin
  41.                 sh := GetString(128 + i);
  42.                 if (sh <> nil) then
  43.                     aActionMsg[i] := sh^^;
  44.                 i := i + 1;
  45.             end;
  46.         until not ((i < ActionMsgNumber) and (sh <> nil));
  47.  
  48.         SATGetPort(tmpPort);
  49.         DrawProgInfo(playerSp);
  50.         SetRect(r, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  51.         SATBackChanged(r); (*Let SAT show it on screen*)
  52.         SATSetPort(tmpPort);
  53.     end; {InitInformationArea}
  54.  
  55.     procedure DrawProgInfo (me: PlSpritePtr);
  56.         var
  57.             s: Str255;
  58.             r: Rect;
  59.     begin
  60.         SetPort(gSAT.backScreen.port);
  61.         BackColor(blackColor);
  62.  
  63.         SetRect(r, 0, 0, gSAT.bounds.right, 18);
  64.  
  65.         ForeColor(blueColor);
  66.         EraseRect(r);
  67.         PenNormal;
  68.  
  69.         FrameRect(r);
  70.         SetRect(r, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  71.         FrameRect(r);
  72.  
  73.         ForeColor(redColor);
  74.         MoveTo(10, 13);
  75.         DrawString('This is a Demo for Scrolling and Platform Game.(made by Nissan Zafrir 1995)');
  76.  
  77.         SetRect(r, 1, 350, gSAT.offSizeH - 150, 366);
  78.         EraseRect(r);
  79.         ForeColor(yellowColor);
  80.  
  81.         MoveTo(10, 362);
  82.         DrawString('Speed.V = ');
  83.  
  84. (*** Displaying SpeedV info ***\}
  85. {NumToString(me->speed.v, s);}
  86. {MoveTo(100, 362);}
  87. {DrawString("\pSpeed.V = ");}
  88. {MoveTo(170, 362);}
  89. {DrawString(s);}
  90. {*******************************)
  91.         MoveTo(110, 362);
  92.         DrawString('Action = ');
  93.  
  94.         MoveTo(700, 362);
  95.         DrawString('H = ');
  96.  
  97. (*** Displaying PositionV info ***\}
  98. {MoveTo(350,362);}
  99. {DrawString("\pV = ");}
  100. {MoveTo(370,362);}
  101. {NumToString(me->position.v, s);}
  102. {DrawString(s);}
  103. {**********************************)
  104.         ForeColor(blackColor);
  105.         BackColor(whiteColor);
  106.     end; {DrawProgInfo}
  107.  
  108.     procedure UpdateInfo (me: PlSpritePtr);
  109.         var
  110.             s: Str255;
  111.             sh: StringHandle;
  112.             r: Rect;
  113.     begin
  114.         BackColor(blackColor);
  115.         ForeColor(yellowColor);
  116.  
  117.         SetRect(r, 80, 350, 110, 366);
  118.         EraseRect(r);
  119.         NumToString(me^.speed.v, s);
  120.         MoveTo(80, 362);
  121.         DrawString(s);
  122.  
  123.         if (me^.action <> lastActMsg) then
  124.             begin
  125.                 SetRect(r, 165, 350, 310, 366);
  126.                 EraseRect(r);
  127.                 MoveTo(165, 362);
  128.                 lastActMsg := me^.action;
  129.                 DrawString(aActionMsg[lastActMsg]);
  130.             end;
  131.         SetRect(r, 720, 350, 750, 366);
  132.         EraseRect(r);
  133.         MoveTo(720, 362);
  134.         NumToString(me^.position.h, s);
  135.         DrawString(s);
  136.  
  137.         ForeColor(blackColor);
  138.         BackColor(whiteColor);
  139.     end; {UpdateInfo}
  140.  
  141.     procedure DrawProgrammerInfo;
  142.         var
  143.             s: Str255;
  144.             r: Rect;
  145.             tmpPort: SATPort;
  146.     begin
  147.         SATGetPort(tmpPort);
  148.         SATSetPortScreen;
  149.         UpdateInfo(playerSp);
  150.         SATSetPort(tmpPort);
  151.     end; {DrawProgrammerInfo}
  152.  
  153. end.